package com.jiankang.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jiankang.entity.Healthcare;
import com.jiankang.entity.Makeappointment;
import com.jiankang.entity.Medicalcare;
import com.jiankang.entity.MedicalcareInside;
import com.jiankang.service.HatProvinceService;
import com.jiankang.service.HealthcareService;
import com.jiankang.service.MedicalcareInsideService;
import com.jiankang.service.MedicalcareService;
import com.jiankang.util.Page;

@Controller
@RequestMapping("/hathappenedat")
public class MedicalcareController {
	@Resource
	private MedicalcareService medicalcareService;
	@Resource
	private HatProvinceService hatProvinceService;
	
	//加盟
	@Resource
	private HealthcareService healthcareService;
	
	@RequestMapping("/selecthealthcare") 
	public String selecthealthcare(Model model, HttpServletRequest req)throws Exception {
		String pageNow = req.getParameter("pageNow");
		Page page = null;
		List<Healthcare> healthcare=null;
		int totalCount = (int) healthcareService.getAllProductCount();
		if (pageNow != null) {
			page = new Page(totalCount, Integer.parseInt(pageNow));
			healthcare=healthcareService.getHealthFile(page);
		}else{
			page = new Page(totalCount, 1);
			healthcare=healthcareService.getHealthFile(page);
		}
		model.addAttribute("page", page);
		model.addAttribute("healthcare", healthcare);
		return "admin/selecthealthcare";
		
	}
	//预约
	@RequestMapping("/selectmakeapp") 
	public String selectmakeapp(Model model, HttpServletRequest req)throws Exception {
		String pageNow = req.getParameter("pageNow");
		Page page = null;
		List<Makeappointment> makeappointment=null;
		int totalCount = (int) healthcareService.getAllProductCountmakeappointment();
		if (pageNow != null) {
			page = new Page(totalCount, Integer.parseInt(pageNow));
			makeappointment=healthcareService.getHealthFilemakeappointment(page);
		}else{
			page = new Page(totalCount, 1);
			makeappointment=healthcareService.getHealthFilemakeappointment(page);
		}
		model.addAttribute("page", page);
		model.addAttribute("makeappointment", makeappointment);
		return "admin/savemakeapp";
	}
	@RequestMapping("/medicalcare") 
	public String medicalcare(Model model, HttpServletRequest req)throws Exception {
		String pageNow = req.getParameter("pageNow");
		Page page = null;
		List<Medicalcare> medicalcare=null;
		int totalCount = (int) medicalcareService.getAllProductCount();
		if (pageNow != null) {
			page = new Page(totalCount, Integer.parseInt(pageNow));
			medicalcare=medicalcareService.getHealthFile(page);
		}else{
			page = new Page(totalCount, 1);
			medicalcare=medicalcareService.getHealthFile(page);
		}
		model.addAttribute("page", page);
		model.addAttribute("medicalcare", medicalcare);
		return "admin/medicalcare";
	}
	@Resource
	private MedicalcareInsideService medicalcareInsideService;
	@RequestMapping("/detailsoftheintroduction/{picId}") 
	public String detailsoftheintroduction(@PathVariable("picId") int picId,Model model)throws Exception {
		List<MedicalcareInside> medicalcareInside=medicalcareInsideService.selectpic(picId);
		model.addAttribute("medicalcareInside", medicalcareInside);
		return "admin/medicalcareInside";
	}
}
